package com.atzxh.io.bio.four;

import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author 小红同学
 * @create 2023-04-11-18:55
 * @description  实现伪异步服务架构
 */
public class Server {
    public static void main(String[] args) {
        try {
            ServerSocket server = new ServerSocket(9999);
            // 初始化一个线程池对象
            ServerThreadPool threadPool = new ServerThreadPool(6, 10);
            while (true) {
                Socket socket = server.accept();
                // 把socket对象交给线程池处理
                // 封装成一个任务现象
                Runnable target = new ServerRunnableTarget(socket);
                target.run();
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
    }
}
